<template>
  <div :class="className" :style="{height:height,width:width}" />
</template>

<script>
import * as echarts from 'echarts'
require('echarts/theme/macarons') // echarts theme
import resize from './mixins/resize'

const animationDuration = 6000

export default {
  mixins: [resize],
  props: {
    className: {
      type: String,
      default: 'chart'
    },
    width: {
      type: String,
      default: '100%'
    },
    height: {
      type: String,
      default: '300px'
    }
  },
  data() {
    return {
      chart: null
    }
  },
  mounted() {
    this.$nextTick(() => {
      this.initChart()
    })
  },
  beforeDestroy() {
    if (!this.chart) {
      return
    }
    this.chart.dispose()
    this.chart = null
  },
  methods: {
    initChart() {
      this.chart = echarts.init(this.$el, 'macarons')

      this.chart.setOption({

        title : {
          text: '出土垃圾类型',
          x:'center'
        },
        
    tooltip: {
        trigger: 'item' // 触发类型，'item' 表示数据项图形触发，'axis' 表示坐标轴触发
    }, 
   
  series: [
    {
      name: '出土垃圾类型',
      type: 'pie',
      radius: [50, 120],
      center: ['50%', '50%'],
      roseType: 'area',
      itemStyle: {
        borderRadius: 8
      },
      data: [
        { value: 40, name: '普通渣土' },
        { value: 38, name: '沙石' },
        { value: 32, name: '建筑材料' },
        { value: 30, name: '盾构土' },
        { value: 28, name: '拆除垃圾' },
        { value: 26, name: '装潢垃圾' }
      ]
    }
  ]
      })
    }
  }
}
</script>
